/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.cmu.cs.webapp.ioms.models.impl;

import edu.cmu.cs.webapp.ioms.models.FormularRecord;
import edu.cmu.cs.webapp.ioms.models.IOMSPackage;
import edu.cmu.cs.webapp.ioms.models.Product;
import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Product</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.ProductImpl#getProd_id <em>Prod id</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.ProductImpl#getProd_name <em>Prod name</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.ProductImpl#getProd_description <em>Prod description</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.ProductImpl#getProd_image <em>Prod image</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.ProductImpl#getPrice <em>Price</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.ProductImpl#getFormular <em>Formular</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProductImpl extends EObjectImpl implements Product {
	/**
	 * The default value of the '{@link #getProd_id() <em>Prod id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProd_id()
	 * @generated
	 * @ordered
	 */
	protected static final int PROD_ID_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getProd_id() <em>Prod id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProd_id()
	 * @generated
	 * @ordered
	 */
	protected int prod_id = PROD_ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getProd_name() <em>Prod name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProd_name()
	 * @generated
	 * @ordered
	 */
	protected static final String PROD_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getProd_name() <em>Prod name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProd_name()
	 * @generated
	 * @ordered
	 */
	protected String prod_name = PROD_NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getProd_description() <em>Prod description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProd_description()
	 * @generated
	 * @ordered
	 */
	protected static final String PROD_DESCRIPTION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getProd_description() <em>Prod description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProd_description()
	 * @generated
	 * @ordered
	 */
	protected String prod_description = PROD_DESCRIPTION_EDEFAULT;

	/**
	 * The default value of the '{@link #getProd_image() <em>Prod image</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProd_image()
	 * @generated
	 * @ordered
	 */
	protected static final Byte PROD_IMAGE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getProd_image() <em>Prod image</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProd_image()
	 * @generated
	 * @ordered
	 */
	protected Byte prod_image = PROD_IMAGE_EDEFAULT;

	/**
	 * The default value of the '{@link #getPrice() <em>Price</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPrice()
	 * @generated
	 * @ordered
	 */
	protected static final double PRICE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getPrice() <em>Price</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPrice()
	 * @generated
	 * @ordered
	 */
	protected double price = PRICE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getFormular() <em>Formular</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFormular()
	 * @generated
	 * @ordered
	 */
	protected EList<FormularRecord> formular;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProductImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return IOMSPackage.Literals.PRODUCT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getProd_id() {
		return prod_id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setProd_id(int newProd_id) {
		int oldProd_id = prod_id;
		prod_id = newProd_id;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.PRODUCT__PROD_ID, oldProd_id, prod_id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getProd_name() {
		return prod_name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setProd_name(String newProd_name) {
		String oldProd_name = prod_name;
		prod_name = newProd_name;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.PRODUCT__PROD_NAME, oldProd_name, prod_name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getProd_description() {
		return prod_description;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setProd_description(String newProd_description) {
		String oldProd_description = prod_description;
		prod_description = newProd_description;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.PRODUCT__PROD_DESCRIPTION, oldProd_description, prod_description));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Byte getProd_image() {
		return prod_image;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setProd_image(Byte newProd_image) {
		Byte oldProd_image = prod_image;
		prod_image = newProd_image;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.PRODUCT__PROD_IMAGE, oldProd_image, prod_image));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getPrice() {
		return price;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPrice(double newPrice) {
		double oldPrice = price;
		price = newPrice;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.PRODUCT__PRICE, oldPrice, price));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<FormularRecord> getFormular() {
		if (formular == null) {
			formular = new EObjectResolvingEList<FormularRecord>(FormularRecord.class, this, IOMSPackage.PRODUCT__FORMULAR);
		}
		return formular;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case IOMSPackage.PRODUCT__PROD_ID:
				return getProd_id();
			case IOMSPackage.PRODUCT__PROD_NAME:
				return getProd_name();
			case IOMSPackage.PRODUCT__PROD_DESCRIPTION:
				return getProd_description();
			case IOMSPackage.PRODUCT__PROD_IMAGE:
				return getProd_image();
			case IOMSPackage.PRODUCT__PRICE:
				return getPrice();
			case IOMSPackage.PRODUCT__FORMULAR:
				return getFormular();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case IOMSPackage.PRODUCT__PROD_ID:
				setProd_id((Integer)newValue);
				return;
			case IOMSPackage.PRODUCT__PROD_NAME:
				setProd_name((String)newValue);
				return;
			case IOMSPackage.PRODUCT__PROD_DESCRIPTION:
				setProd_description((String)newValue);
				return;
			case IOMSPackage.PRODUCT__PROD_IMAGE:
				setProd_image((Byte)newValue);
				return;
			case IOMSPackage.PRODUCT__PRICE:
				setPrice((Double)newValue);
				return;
			case IOMSPackage.PRODUCT__FORMULAR:
				getFormular().clear();
				getFormular().addAll((Collection<? extends FormularRecord>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case IOMSPackage.PRODUCT__PROD_ID:
				setProd_id(PROD_ID_EDEFAULT);
				return;
			case IOMSPackage.PRODUCT__PROD_NAME:
				setProd_name(PROD_NAME_EDEFAULT);
				return;
			case IOMSPackage.PRODUCT__PROD_DESCRIPTION:
				setProd_description(PROD_DESCRIPTION_EDEFAULT);
				return;
			case IOMSPackage.PRODUCT__PROD_IMAGE:
				setProd_image(PROD_IMAGE_EDEFAULT);
				return;
			case IOMSPackage.PRODUCT__PRICE:
				setPrice(PRICE_EDEFAULT);
				return;
			case IOMSPackage.PRODUCT__FORMULAR:
				getFormular().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case IOMSPackage.PRODUCT__PROD_ID:
				return prod_id != PROD_ID_EDEFAULT;
			case IOMSPackage.PRODUCT__PROD_NAME:
				return PROD_NAME_EDEFAULT == null ? prod_name != null : !PROD_NAME_EDEFAULT.equals(prod_name);
			case IOMSPackage.PRODUCT__PROD_DESCRIPTION:
				return PROD_DESCRIPTION_EDEFAULT == null ? prod_description != null : !PROD_DESCRIPTION_EDEFAULT.equals(prod_description);
			case IOMSPackage.PRODUCT__PROD_IMAGE:
				return PROD_IMAGE_EDEFAULT == null ? prod_image != null : !PROD_IMAGE_EDEFAULT.equals(prod_image);
			case IOMSPackage.PRODUCT__PRICE:
				return price != PRICE_EDEFAULT;
			case IOMSPackage.PRODUCT__FORMULAR:
				return formular != null && !formular.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (prod_id: ");
		result.append(prod_id);
		result.append(", prod_name: ");
		result.append(prod_name);
		result.append(", prod_description: ");
		result.append(prod_description);
		result.append(", prod_image: ");
		result.append(prod_image);
		result.append(", price: ");
		result.append(price);
		result.append(')');
		return result.toString();
	}

} //ProductImpl
